#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long LL;
typedef double db;
inline LL read()
{
	LL x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		x=(x<<1)+(x<<3)+ch-'0';
		ch=getchar();
	}
	return x*f;
}
int n,k;
struct node
{
	LL val;
	int dep;
	bool operator<(const node b)const
	{
		return val==b.val?dep>b.dep:val>b.val;
	}
	void clear()
	{
		val=dep=0;
	}
}ans,tmp1,tmp2;
priority_queue<node>q;
int main()
{
	n=read();k=read();
	for(int i=1;i<=n;++i)
	{
		tmp1.val=read();
		q.push(tmp1);
	}
	if(k>2)
	{
		while(n%(k-1)!=1)
		{
			q.push(tmp2);
			++n;
		}
	}
	while(q.size()!=1)
	{
		tmp2.clear();
		for(int i=1;i<=k;++i)
		{
			tmp1=q.top();
			q.pop();
			tmp2.val+=tmp1.val;
			tmp2.dep=max(tmp2.dep,tmp1.dep+1);
		}
		ans.val+=tmp2.val;
		ans.dep=max(ans.dep,tmp2.dep);
		q.push(tmp2);
	}
	printf("%lld\n%d\n",ans.val,ans.dep);
	return 0;
}
